package com.tac.service.impl;

import com.tac.common.result.Result;
import com.tac.dao.EnterpriseInfoDao;
import com.tac.pojo.EnterpriseInfo;
import com.tac.service.EnterpriseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EnterpriseInfoServiceImpl implements EnterpriseInfoService {

    @Autowired
    private EnterpriseInfoDao enterpriseInfoDao;

    public Result<EnterpriseInfo> getByTargetId(Integer targetId){
        EnterpriseInfo enterpriseInfo = enterpriseInfoDao.getByTargetId(targetId);
        return Result.success(enterpriseInfo);
    }

    public Result save(EnterpriseInfo enterpriseInfo){
        Integer integer = enterpriseInfoDao.save(enterpriseInfo);
        if(integer>0){
            return Result.success(enterpriseInfo);
        }
        return Result.error("添加失败");
    }

    public Result update(EnterpriseInfo enterpriseInfo){
        Integer integer = enterpriseInfoDao.update(enterpriseInfo);
        if(integer>0){
            return Result.success(null);
        }
        return Result.error("修改失败");
    }
}
